'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 活动副本配置
 * @author agl
 */

var _ = require('lodash');
var dataApi = require('../libs/dataApi');

/**
 * 按类型获取副本的配置
 * @return {[type]}     [description]
 */
exports.getCarbonConfByType = function (carbon_type) {
    return dataApi.active_carbon.find({
        type: carbon_type,
        lvl: 1
    });
};

/**
 * 获取副本建筑的配置
 * @param  {[type]} build_type [description]
 * @return {[type]}            [description]
 */
exports.getCarbonBuildConf = function (small_id) {
    return dataApi.active_carbon_config.findById(small_id);
};

/**
 * 按ID获取副本的配置
 * @param  {[type]} carbon_id [description]
 * @return {[type]}         [description]
 */
exports.getCarbonConfById = function (carbon_id) {
    return dataApi.active_carbon.findById(carbon_id);
};

/**
 * 获取奖励信息
 * @param  {[type]} carbon_id [description]
 * @return {[type]}         [description]
 */
exports.getCarbonReward = function (carbon_id) {
    return dataApi.active_carbon_reward.findById(carbon_id);
};

/**
 * 随机出小副本ID
 * @param  {[type]} carbon_id [description]
 * @return {[type]}         [description]
 */
exports.getRandSmallConf = function (carbon_id) {
    var small_list = dataApi.active_small_carbon.findById(carbon_id);
    var rand_idx = _.random(0, small_list.length - 1);
    return small_list[rand_idx];
};
